﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CRMExam.Database;
using System.Threading.Tasks;
using CRMExam.Models;

namespace CRMExam.Controllers
{
    public class InviteUserController : Controller
    {
        [AllowAnonymous]
        public ActionResult Invite(Guid id)
        {
            RegisterViewModel model = new RegisterViewModel();

            InvitedUser invitedUser;

            using (CRMExam1Entities context = new CRMExam1Entities())
            {
                invitedUser = context.InvitedUsers.FirstOrDefault(i => i.Id == id);
            }

            if (invitedUser != null)
            {
                model.Guid = id;
                model.CustomerId = (Guid)invitedUser.CustomerId;
                return View(model);     
            }

            return Redirect("http://www.google.com");
        }
	}
}